def decodeString(s):
    def decode(i):
        #变量
        res, num = "", 0

        while i < len(s):
            if "0" <= s[i] <= "9":
                num = 10 * num + int(s[i])
            elif s[i] == '[':
                i, tmp = decode(i+1)
                res = res + num * tmp
                num = 0
            elif s[i] == ']':
                return i, res
            else:
                res = res + s[i]
            i += 1
        return res
    return decode(0)


print(decodeString("3[a]2[bc]"))